home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / os.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  24KB  |  799 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. """OS routines for Mac, NT, or Posix depending on what system we're on.
  5.  
  6. This exports:
  7.   - all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
  8.   - os.path is one of the modules posixpath, or ntpath
  9.   - os.name is 'posix', 'nt', 'os2', 'ce' or 'riscos'
  10.   - os.curdir is a string representing the current directory ('.' or ':')
  11.   - os.pardir is a string representing the parent directory ('..' or '::')
  12.   - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\\\')
  13.   - os.extsep is the extension separator ('.' or '/')
  14.   - os.altsep is the alternate pathname separator (None or '/')
  15.   - os.pathsep is the component separator used in $PATH etc
  16.   - os.linesep is the line separator in text files ('\\r' or '\\n' or '\\r\\n')
  17.   - os.defpath is the default search path for executables
  18.   - os.devnull is the file path of the null device ('/dev/null', etc.)
  19.  
  20. Programs that import and use 'os' stand a better chance of being
  21. portable between different platforms.  Of course, they must then
  22. only use functions that are defined by all platforms (e.g., unlink
  23. and opendir), and leave all pathname manipulation to os.path
  24. (e.g., split and join).
  25. """
  26. import sys
  27. import errno
  28. _names = sys.builtin_module_names
  29. __all__ = [
  30.     'altsep',
  31.     'curdir',
  32.     'pardir',
  33.     'sep',
  34.     'extsep',
  35.     'pathsep',
  36.     'linesep',
  37.     'defpath',
  38.     'name',
  39.     'path',
  40.     'devnull',
  41.     'SEEK_SET',
  42.     'SEEK_CUR',
  43.     'SEEK_END']
  44.  
  45. def _get_exports_list(module):
  46.     
  47.     try:
  48.         return list(module.__all__)
  49.     except AttributeError:
  50.         return [ n for n in dir(module) if n[0] != '_' ]
  51.  
  52.  
  53. if 'posix' in _names:
  54.     name = 'posix'
  55.     linesep = '\n'
  56.     from posix import *
  57.     
  58.     try:
  59.         from posix import _exit
  60.     except ImportError:
  61.         pass
  62.  
  63.     import posixpath as path
  64.     import posix
  65.     __all__.extend(_get_exports_list(posix))
  66.     del posix
  67. elif 'nt' in _names:
  68.     name = 'nt'
  69.     linesep = '\r\n'
  70.     from nt import *
  71.     
  72.     try:
  73.         from nt import _exit
  74.     except ImportError:
  75.         pass
  76.  
  77.     import ntpath as path
  78.     import nt
  79.     __all__.extend(_get_exports_list(nt))
  80.     del nt
  81. elif 'os2' in _names:
  82.     name = 'os2'
  83.     linesep = '\r\n'
  84.     from os2 import *
  85.     
  86.     try:
  87.         from os2 import _exit
  88.     except ImportError:
  89.         pass
  90.  
  91.     if sys.version.find('EMX GCC') == -1:
  92.         import ntpath as path
  93.     else:
  94.         import os2emxpath as path
  95.         from _emx_link import link
  96.     import os2
  97.     __all__.extend(_get_exports_list(os2))
  98.     del os2
  99. elif 'ce' in _names:
  100.     name = 'ce'
  101.     linesep = '\r\n'
  102.     from ce import *
  103.     
  104.     try:
  105.         from ce import _exit
  106.     except ImportError:
  107.         pass
  108.  
  109.     import ntpath as path
  110.     import ce
  111.     __all__.extend(_get_exports_list(ce))
  112.     del ce
  113. elif 'riscos' in _names:
  114.     name = 'riscos'
  115.     linesep = '\n'
  116.     from riscos import *
  117.     
  118.     try:
  119.         from riscos import _exit
  120.     except ImportError:
  121.         pass
  122.  
  123.     import riscospath as path
  124.     import riscos
  125.     __all__.extend(_get_exports_list(riscos))
  126.     del riscos
  127. else:
  128.     raise ImportError, 'no os specific module found'
  129. sys.modules['os.path'] = None
  130. from os.path import curdir, pardir, sep, pathsep, defpath, extsep, altsep, devnull
  131. del _names
  132. SEEK_SET = 0
  133. SEEK_CUR = 1
  134. SEEK_END = 2
  135.  
  136. def makedirs(name, mode = 511):
  137.     '''makedirs(path [, mode=0777])
  138.  
  139.     Super-mkdir; create a leaf directory and all intermediate ones.
  140.     Works like mkdir, except that any intermediate path segment (not
  141.     just the rightmost) will be created if it does not exist.  This is
  142.     recursive.
  143.  
  144.     '''
  145.     (head, tail) = path.split(name)
  146.     if not tail:
  147.         (head, tail) = path.split(head)
  148.     if head and tail and not path.exists(head):
  149.         
  150.         try:
  151.             makedirs(head, mode)
  152.         except OSError:
  153.             e = None
  154.             if e.errno != errno.EEXIST:
  155.                 raise 
  156.  
  157.         if tail == curdir:
  158.             return None
  159.     mkdir(name, mode)
  160.  
  161.  
  162. def removedirs(name):
  163.     '''removedirs(path)
  164.  
  165.     Super-rmdir; remove a leaf directory and all empty intermediate
  166.     ones.  Works like rmdir except that, if the leaf directory is
  167.     successfully removed, directories corresponding to rightmost path
  168.     segments will be pruned away until either the whole path is
  169.     consumed or an error occurs.  Errors during this latter phase are
  170.     ignored -- they generally mean that a directory was not empty.
  171.  
  172.     '''
  173.     rmdir(name)
  174.     (head, tail) = path.split(name)
  175.     if not tail:
  176.         (head, tail) = path.split(head)
  177.     while head and tail:
  178.         
  179.         try:
  180.             rmdir(head)
  181.         except error:
  182.             break
  183.  
  184.         (head, tail) = path.split(head)
  185.  
  186.  
  187. def renames(old, new):
  188.     '''renames(old, new)
  189.  
  190.     Super-rename; create directories as necessary and delete any left
  191.     empty.  Works like rename, except creation of any intermediate
  192.     directories needed to make the new pathname good is attempted
  193.     first.  After the rename, directories corresponding to rightmost
  194.     path segments of the old name will be pruned way until either the
  195.     whole path is consumed or a nonempty directory is found.
  196.  
  197.     Note: this function can fail with the new directory structure made
  198.     if you lack permissions needed to unlink the leaf directory or
  199.     file.
  200.  
  201.     '''
  202.     (head, tail) = path.split(new)
  203.     if head and tail and not path.exists(head):
  204.         makedirs(head)
  205.     rename(old, new)
  206.     (head, tail) = path.split(old)
  207.     if head and tail:
  208.         
  209.         try:
  210.             removedirs(head)
  211.         except error:
  212.             pass
  213.         
  214.  
  215.  
  216. __all__.extend([
  217.     'makedirs',
  218.     'removedirs',
  219.     'renames'])
  220.  
  221. def walk(top, topdown = True, onerror = None, followlinks = False):
  222.     '''Directory tree generator.
  223.  
  224.     For each directory in the directory tree rooted at top (including top
  225.     itself, but excluding \'.\' and \'..\'), yields a 3-tuple
  226.  
  227.         dirpath, dirnames, filenames
  228.  
  229.     dirpath is a string, the path to the directory.  dirnames is a list of
  230.     the names of the subdirectories in dirpath (excluding \'.\' and \'..\').
  231.     filenames is a list of the names of the non-directory files in dirpath.
  232.     Note that the names in the lists are just names, with no path components.
  233.     To get a full path (which begins with top) to a file or directory in
  234.     dirpath, do os.path.join(dirpath, name).
  235.  
  236.     If optional arg \'topdown\' is true or not specified, the triple for a
  237.     directory is generated before the triples for any of its subdirectories
  238.     (directories are generated top down).  If topdown is false, the triple
  239.     for a directory is generated after the triples for all of its
  240.     subdirectories (directories are generated bottom up).
  241.  
  242.     When topdown is true, the caller can modify the dirnames list in-place
  243.     (e.g., via del or slice assignment), and walk will only recurse into the
  244.     subdirectories whose names remain in dirnames; this can be used to prune
  245.     the search, or to impose a specific order of visiting.  Modifying
  246.     dirnames when topdown is false is ineffective, since the directories in
  247.     dirnames have already been generated by the time dirnames itself is
  248.     generated.
  249.  
  250.     By default errors from the os.listdir() call are ignored.  If
  251.     optional arg \'onerror\' is specified, it should be a function; it
  252.     will be called with one argument, an os.error instance.  It can
  253.     report the error to continue with the walk, or raise the exception
  254.     to abort the walk.  Note that the filename is available as the
  255.     filename attribute of the exception object.
  256.  
  257.     By default, os.walk does not follow symbolic links to subdirectories on
  258.     systems that support them.  In order to get this functionality, set the
  259.     optional argument \'followlinks\' to true.
  260.  
  261.     Caution:  if you pass a relative pathname for top, don\'t change the
  262.     current working directory between resumptions of walk.  walk never
  263.     changes the current directory, and assumes that the client doesn\'t
  264.     either.
  265.  
  266.     Example:
  267.  
  268.     import os
  269.     from os.path import join, getsize
  270.     for root, dirs, files in os.walk(\'python/Lib/email\'):
  271.         print root, "consumes",
  272.         print sum([getsize(join(root, name)) for name in files]),
  273.         print "bytes in", len(files), "non-directory files"
  274.         if \'CVS\' in dirs:
  275.             dirs.remove(\'CVS\')  # don\'t visit CVS directories
  276.     '''
  277.     islink = path.islink
  278.     join = path.join
  279.     isdir = path.isdir
  280.     
  281.     try:
  282.         names = listdir(top)
  283.     except error:
  284.         err = None
  285.         if onerror is not None:
  286.             onerror(err)
  287.         return None
  288.  
  289.     dirs = []
  290.     nondirs = []
  291.     for name in names:
  292.         if isdir(join(top, name)):
  293.             dirs.append(name)
  294.             continue
  295.         nondirs.append(name)
  296.     
  297.     if topdown:
  298.         yield (top, dirs, nondirs)
  299.     for name in dirs:
  300.         new_path = join(top, name)
  301.         if not followlinks:
  302.             if not islink(new_path):
  303.                 for x in walk(new_path, topdown, onerror, followlinks):
  304.                     yield x
  305.                 
  306.             if not topdown:
  307.                 yield (top, dirs, nondirs)
  308.             return None
  309.  
  310. __all__.append('walk')
  311.  
  312. try:
  313.     environ
  314. except NameError:
  315.     environ = { }
  316.  
  317.  
  318. def execl(file, *args):
  319.     '''execl(file, *args)
  320.  
  321.     Execute the executable file with argument list args, replacing the
  322.     current process. '''
  323.     execv(file, args)
  324.  
  325.  
  326. def execle(file, *args):
  327.     '''execle(file, *args, env)
  328.  
  329.     Execute the executable file with argument list args and
  330.     environment env, replacing the current process. '''
  331.     env = args[-1]
  332.     execve(file, args[:-1], env)
  333.  
  334.  
  335. def execlp(file, *args):
  336.     '''execlp(file, *args)
  337.  
  338.     Execute the executable file (which is searched for along $PATH)
  339.     with argument list args, replacing the current process. '''
  340.     execvp(file, args)
  341.  
  342.  
  343. def execlpe(file, *args):
  344.     '''execlpe(file, *args, env)
  345.  
  346.     Execute the executable file (which is searched for along $PATH)
  347.     with argument list args and environment env, replacing the current
  348.     process. '''
  349.     env = args[-1]
  350.     execvpe(file, args[:-1], env)
  351.  
  352.  
  353. def execvp(file, args):
  354.     '''execvp(file, args)
  355.  
  356.     Execute the executable file (which is searched for along $PATH)
  357.     with argument list args, replacing the current process.
  358.     args may be a list or tuple of strings. '''
  359.     _execvpe(file, args)
  360.  
  361.  
  362. def execvpe(file, args, env):
  363.     '''execvpe(file, args, env)
  364.  
  365.     Execute the executable file (which is searched for along $PATH)
  366.     with argument list args and environment env , replacing the
  367.     current process.
  368.     args may be a list or tuple of strings. '''
  369.     _execvpe(file, args, env)
  370.  
  371. __all__.extend([
  372.     'execl',
  373.     'execle',
  374.     'execlp',
  375.     'execlpe',
  376.     'execvp',
  377.     'execvpe'])
  378.  
  379. def _execvpe(file, args, env = None):
  380.     if env is not None:
  381.         func = execve
  382.         argrest = (args, env)
  383.     else:
  384.         func = execv
  385.         argrest = (args,)
  386.         env = environ
  387.     (head, tail) = path.split(file)
  388.     if head:
  389.         func(file, *argrest)
  390.         return None
  391.     if None in env:
  392.         envpath = env['PATH']
  393.     else:
  394.         envpath = defpath
  395.     PATH = envpath.split(pathsep)
  396.     saved_exc = None
  397.     saved_tb = None
  398.     for dir in PATH:
  399.         fullname = path.join(dir, file)
  400.         
  401.         try:
  402.             func(fullname, *argrest)
  403.         continue
  404.         except error:
  405.             e = None
  406.             tb = sys.exc_info()[2]
  407.             if e.errno != errno.ENOENT and e.errno != errno.ENOTDIR and saved_exc is None:
  408.                 saved_exc = e
  409.                 saved_tb = tb
  410.             
  411.         
  412.  
  413.     
  414.     if saved_exc:
  415.         raise error, saved_exc, saved_tb
  416.     raise error, e, tb
  417.  
  418.  
  419. try:
  420.     putenv
  421. except NameError:
  422.     pass
  423.  
  424. import UserDict
  425. if name in ('os2', 'nt'):
  426.     
  427.     def unsetenv(key):
  428.         putenv(key, '')
  429.  
  430. if name == 'riscos':
  431.     from riscosenviron import _Environ
  432. elif name in ('os2', 'nt'):
  433.     
  434.     class _Environ(UserDict.IterableUserDict):
  435.         
  436.         def __init__(self, environ):
  437.             UserDict.UserDict.__init__(self)
  438.             data = self.data
  439.             for k, v in environ.items():
  440.                 data[k.upper()] = v
  441.             
  442.  
  443.         
  444.         def __setitem__(self, key, item):
  445.             putenv(key, item)
  446.             self.data[key.upper()] = item
  447.  
  448.         
  449.         def __getitem__(self, key):
  450.             return self.data[key.upper()]
  451.  
  452.         
  453.         try:
  454.             unsetenv
  455.         except NameError:
  456.             
  457.             def __delitem__(self, key):
  458.                 del self.data[key.upper()]
  459.  
  460.  
  461.         
  462.         def __delitem__(self, key):
  463.             unsetenv(key)
  464.             del self.data[key.upper()]
  465.  
  466.         
  467.         def clear(self):
  468.             for key in self.data.keys():
  469.                 unsetenv(key)
  470.                 del self.data[key]
  471.             
  472.  
  473.         
  474.         def pop(self, key, *args):
  475.             unsetenv(key)
  476.             return self.data.pop(key.upper(), *args)
  477.  
  478.         
  479.         def has_key(self, key):
  480.             return key.upper() in self.data
  481.  
  482.         
  483.         def __contains__(self, key):
  484.             return key.upper() in self.data
  485.  
  486.         
  487.         def get(self, key, failobj = None):
  488.             return self.data.get(key.upper(), failobj)
  489.  
  490.         
  491.         def update(self, dict = None, **kwargs):
  492.             if dict:
  493.                 
  494.                 try:
  495.                     keys = dict.keys()
  496.                 except AttributeError:
  497.                     for k, v in dict:
  498.                         self[k] = v
  499.                     
  500.  
  501.                 for k in keys:
  502.                     self[k] = dict[k]
  503.                 
  504.             if kwargs:
  505.                 self.update(kwargs)
  506.  
  507.         
  508.         def copy(self):
  509.             return dict(self)
  510.  
  511.  
  512. else:
  513.     
  514.     class _Environ(UserDict.IterableUserDict):
  515.         
  516.         def __init__(self, environ):
  517.             UserDict.UserDict.__init__(self)
  518.             self.data = environ
  519.  
  520.         
  521.         def __setitem__(self, key, item):
  522.             putenv(key, item)
  523.             self.data[key] = item
  524.  
  525.         
  526.         def update(self, dict = None, **kwargs):
  527.             if dict:
  528.                 
  529.                 try:
  530.                     keys = dict.keys()
  531.                 except AttributeError:
  532.                     for k, v in dict:
  533.                         self[k] = v
  534.                     
  535.  
  536.                 for k in keys:
  537.                     self[k] = dict[k]
  538.                 
  539.             if kwargs:
  540.                 self.update(kwargs)
  541.  
  542.         
  543.         try:
  544.             unsetenv
  545.         except NameError:
  546.             pass
  547.  
  548.         
  549.         def __delitem__(self, key):
  550.             unsetenv(key)
  551.             del self.data[key]
  552.  
  553.         
  554.         def clear(self):
  555.             for key in self.data.keys():
  556.                 unsetenv(key)
  557.                 del self.data[key]
  558.             
  559.  
  560.         
  561.         def pop(self, key, *args):
  562.             unsetenv(key)
  563.             return self.data.pop(key, *args)
  564.  
  565.         
  566.         def copy(self):
  567.             return dict(self)
  568.  
  569.  
  570. environ = _Environ(environ)
  571.  
  572. def getenv(key, default = None):
  573.     """Get an environment variable, return None if it doesn't exist.
  574.     The optional second argument can specify an alternate default."""
  575.     return environ.get(key, default)
  576.  
  577. __all__.append('getenv')
  578.  
  579. def _exists(name):
  580.     return name in globals()
  581.  
  582. if _exists('fork') and not _exists('spawnv') and _exists('execv'):
  583.     P_WAIT = 0
  584.     P_NOWAIT = P_NOWAITO = 1
  585.     
  586.     def _spawnvef(mode, file, args, env, func):
  587.         pid = fork()
  588.         if not pid:
  589.             
  590.             try:
  591.                 if env is None:
  592.                     func(file, args)
  593.                 else:
  594.                     func(file, args, env)
  595.             _exit(127)
  596.  
  597.         elif mode == P_NOWAIT:
  598.             return pid
  599.         while None:
  600.             (wpid, sts) = waitpid(pid, 0)
  601.             if WIFSTOPPED(sts):
  602.                 continue
  603.                 continue
  604.             if WIFSIGNALED(sts):
  605.                 return -WTERMSIG(sts)
  606.             if None(sts):
  607.                 return WEXITSTATUS(sts)
  608.             raise None, 'Not stopped, signaled or exited???'
  609.             continue
  610.             return None
  611.  
  612.     
  613.     def spawnv(mode, file, args):
  614.         """spawnv(mode, file, args) -> integer
  615.  
  616. Execute file with arguments from args in a subprocess.
  617. If mode == P_NOWAIT return the pid of the process.
  618. If mode == P_WAIT return the process's exit code if it exits normally;
  619. otherwise return -SIG, where SIG is the signal that killed it. """
  620.         return _spawnvef(mode, file, args, None, execv)
  621.  
  622.     
  623.     def spawnve(mode, file, args, env):
  624.         """spawnve(mode, file, args, env) -> integer
  625.  
  626. Execute file with arguments from args in a subprocess with the
  627. specified environment.
  628. If mode == P_NOWAIT return the pid of the process.
  629. If mode == P_WAIT return the process's exit code if it exits normally;
  630. otherwise return -SIG, where SIG is the signal that killed it. """
  631.         return _spawnvef(mode, file, args, env, execve)
  632.  
  633.     
  634.     def spawnvp(mode, file, args):
  635.         """spawnvp(mode, file, args) -> integer
  636.  
  637. Execute file (which is looked for along $PATH) with arguments from
  638. args in a subprocess.
  639. If mode == P_NOWAIT return the pid of the process.
  640. If mode == P_WAIT return the process's exit code if it exits normally;
  641. otherwise return -SIG, where SIG is the signal that killed it. """
  642.         return _spawnvef(mode, file, args, None, execvp)
  643.  
  644.     
  645.     def spawnvpe(mode, file, args, env):
  646.         """spawnvpe(mode, file, args, env) -> integer
  647.  
  648. Execute file (which is looked for along $PATH) with arguments from
  649. args in a subprocess with the supplied environment.
  650. If mode == P_NOWAIT return the pid of the process.
  651. If mode == P_WAIT return the process's exit code if it exits normally;
  652. otherwise return -SIG, where SIG is the signal that killed it. """
  653.         return _spawnvef(mode, file, args, env, execvpe)
  654.  
  655. if _exists('spawnv'):
  656.     
  657.     def spawnl(mode, file, *args):
  658.         """spawnl(mode, file, *args) -> integer
  659.  
  660. Execute file with arguments from args in a subprocess.
  661. If mode == P_NOWAIT return the pid of the process.
  662. If mode == P_WAIT return the process's exit code if it exits normally;
  663. otherwise return -SIG, where SIG is the signal that killed it. """
  664.         return spawnv(mode, file, args)
  665.  
  666.     
  667.     def spawnle(mode, file, *args):
  668.         """spawnle(mode, file, *args, env) -> integer
  669.  
  670. Execute file with arguments from args in a subprocess with the
  671. supplied environment.
  672. If mode == P_NOWAIT return the pid of the process.
  673. If mode == P_WAIT return the process's exit code if it exits normally;
  674. otherwise return -SIG, where SIG is the signal that killed it. """
  675.         env = args[-1]
  676.         return spawnve(mode, file, args[:-1], env)
  677.  
  678.     __all__.extend([
  679.         'spawnv',
  680.         'spawnve',
  681.         'spawnl',
  682.         'spawnle'])
  683. if _exists('spawnvp'):
  684.     
  685.     def spawnlp(mode, file, *args):
  686.         """spawnlp(mode, file, *args) -> integer
  687.  
  688. Execute file (which is looked for along $PATH) with arguments from
  689. args in a subprocess with the supplied environment.
  690. If mode == P_NOWAIT return the pid of the process.
  691. If mode == P_WAIT return the process's exit code if it exits normally;
  692. otherwise return -SIG, where SIG is the signal that killed it. """
  693.         return spawnvp(mode, file, args)
  694.  
  695.     
  696.     def spawnlpe(mode, file, *args):
  697.         """spawnlpe(mode, file, *args, env) -> integer
  698.  
  699. Execute file (which is looked for along $PATH) with arguments from
  700. args in a subprocess with the supplied environment.
  701. If mode == P_NOWAIT return the pid of the process.
  702. If mode == P_WAIT return the process's exit code if it exits normally;
  703. otherwise return -SIG, where SIG is the signal that killed it. """
  704.         env = args[-1]
  705.         return spawnvpe(mode, file, args[:-1], env)
  706.  
  707.     __all__.extend([
  708.         'spawnvp',
  709.         'spawnvpe',
  710.         'spawnlp',
  711.         'spawnlpe'])
  712. if _exists('fork'):
  713.     if not _exists('popen2'):
  714.         
  715.         def popen2(cmd, mode = 't', bufsize = -1):
  716.             """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
  717.             may be a sequence, in which case arguments will be passed directly to
  718.             the program without shell intervention (as with os.spawnv()).  If 'cmd'
  719.             is a string it will be passed to the shell (as with os.system()). If
  720.             'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
  721.             file objects (child_stdin, child_stdout) are returned."""
  722.             import warnings as warnings
  723.             msg = 'os.popen2 is deprecated.  Use the subprocess module.'
  724.             warnings.warn(msg, DeprecationWarning, stacklevel = 2)
  725.             import subprocess as subprocess
  726.             PIPE = subprocess.PIPE
  727.             p = subprocess.Popen(cmd, shell = isinstance(cmd, basestring), bufsize = bufsize, stdin = PIPE, stdout = PIPE, close_fds = True)
  728.             return (p.stdin, p.stdout)
  729.  
  730.         __all__.append('popen2')
  731.     if not _exists('popen3'):
  732.         
  733.         def popen3(cmd, mode = 't', bufsize = -1):
  734.             """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
  735.             may be a sequence, in which case arguments will be passed directly to
  736.             the program without shell intervention (as with os.spawnv()).  If 'cmd'
  737.             is a string it will be passed to the shell (as with os.system()). If
  738.             'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
  739.             file objects (child_stdin, child_stdout, child_stderr) are returned."""
  740.             import warnings
  741.             msg = 'os.popen3 is deprecated.  Use the subprocess module.'
  742.             warnings.warn(msg, DeprecationWarning, stacklevel = 2)
  743.             import subprocess
  744.             PIPE = subprocess.PIPE
  745.             p = subprocess.Popen(cmd, shell = isinstance(cmd, basestring), bufsize = bufsize, stdin = PIPE, stdout = PIPE, stderr = PIPE, close_fds = True)
  746.             return (p.stdin, p.stdout, p.stderr)
  747.  
  748.         __all__.append('popen3')
  749.     if not _exists('popen4'):
  750.         
  751.         def popen4(cmd, mode = 't', bufsize = -1):
  752.             """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
  753.             may be a sequence, in which case arguments will be passed directly to
  754.             the program without shell intervention (as with os.spawnv()).  If 'cmd'
  755.             is a string it will be passed to the shell (as with os.system()). If
  756.             'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
  757.             file objects (child_stdin, child_stdout_stderr) are returned."""
  758.             import warnings
  759.             msg = 'os.popen4 is deprecated.  Use the subprocess module.'
  760.             warnings.warn(msg, DeprecationWarning, stacklevel = 2)
  761.             import subprocess
  762.             PIPE = subprocess.PIPE
  763.             p = subprocess.Popen(cmd, shell = isinstance(cmd, basestring), bufsize = bufsize, stdin = PIPE, stdout = PIPE, stderr = subprocess.STDOUT, close_fds = True)
  764.             return (p.stdin, p.stdout)
  765.  
  766.         __all__.append('popen4')
  767.     
  768. import copy_reg as _copy_reg
  769.  
  770. def _make_stat_result(tup, dict):
  771.     return stat_result(tup, dict)
  772.  
  773.  
  774. def _pickle_stat_result(sr):
  775.     (type, args) = sr.__reduce__()
  776.     return (_make_stat_result, args)
  777.  
  778.  
  779. try:
  780.     _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result)
  781. except NameError:
  782.     pass
  783.  
  784.  
  785. def _make_statvfs_result(tup, dict):
  786.     return statvfs_result(tup, dict)
  787.  
  788.  
  789. def _pickle_statvfs_result(sr):
  790.     (type, args) = sr.__reduce__()
  791.     return (_make_statvfs_result, args)
  792.  
  793.  
  794. try:
  795.     _copy_reg.pickle(statvfs_result, _pickle_statvfs_result, _make_statvfs_result)
  796. except NameError:
  797.     pass
  798.  
  799.